package com.newidea.jiangong.utils;

import cn.hutool.core.collection.CollUtil;
import com.newidea.jiangong.dto.Boiler;
import com.newidea.jiangong.dto.FacilityState;
import com.newidea.jiangong.dto.HeatSys;
import com.newidea.jiangong.dto.Pump;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import static com.newidea.jiangong.dto.Boiler.createBoiler;
import static com.newidea.jiangong.dto.FacilityState.createFacilityState;

public class DatunUtil {

    /**
     * 获取供热系统相关的数据
     *
     * @param facilityMap 大屯设备地址:值map
     * @return 供热系统相关的数据
     */
    public static HeatSys getHeatSys(Map<String, String> facilityMap) {
        // 大屯供热系统相关数据地址集合
        List<String> sysAddressList = CollUtil.newArrayList(
            null, "40089", "40091", "40093", "40095", "40073", "40097", "40099",
            "40075", null, null, null, null, null, null
        );
        return HeatSys.createHeatSys(facilityMap, sysAddressList);
    }

    /**
     * 获取泵相关数据集合，如：循环泵、补水泵
     *
     * @param facilityMap 大屯设备地址:值map
     * @return 泵相关数据集合
     */
    public static List<Boiler> getBoilerList(Map<String, String> facilityMap) {
        // 大屯锅炉数据
        List<Boiler> boilerList = new ArrayList<>();
        // 锅炉1相关数据地址集合
        List<String> boilerAddressList1 = CollUtil.newArrayList(
            "40001", "40003", "40009", "40011", "40077", null, "40005", null, null,
            "40007", "40013", "40015", null, "40017", null, null, null, null, null, null
        );
        boilerList.add(createBoiler("锅炉1", facilityMap, boilerAddressList1));

        // 锅炉2相关数据地址集合
        List<String> boilerAddressList2 = CollUtil.newArrayList(
            "40019", "40021", "40027", "40029", "40079", null, "40079", null, null,
            "40025", "40031", "40033", null, "40035", null, null, null, null, null, null
        );
        boilerList.add(createBoiler("锅炉2", facilityMap, boilerAddressList2));

        // 锅炉3相关数据地址集合
        List<String> boilerAddressList3 = CollUtil.newArrayList(
            "40037", "40039", "40045", "40047", "40081", null, "40041", null, null,
            "40043", "40049", "40051", null, "40053", null, null, null, null, null, null
        );
        boilerList.add(createBoiler("锅炉3", facilityMap, boilerAddressList3));

        // 锅炉4相关数据地址集合
        List<String> boilerAddressList4 = CollUtil.newArrayList(
            "40055", "40057", "40063", "40065", "40083", null, "40059", null, null,
            "40061", "40067", "40069", null, "40071", null, null, null, null, null, null
        );
        boilerList.add(createBoiler("锅炉4", facilityMap, boilerAddressList4));
        return boilerList;
    }

    /**
     * 获取泵相关数据集合，如：循环泵、补水泵
     *
     * @param facilityMap 大屯设备地址:值map
     * @return 泵相关数据集合
     */
    public static List<Pump> getPumpList(Map<String, String> facilityMap) {
        // 泵相关数据地址集合
        List<Pump> pumpList = new ArrayList<>();
        pumpList.add(new Pump("循环泵1", facilityMap.get("40101"), "-"));
        pumpList.add(new Pump("循环泵2", facilityMap.get("40103"), "-"));
        pumpList.add(new Pump("循环泵3", facilityMap.get("40105"), "-"));
        pumpList.add(new Pump("补水泵1", "-", "-"));
        pumpList.add(new Pump("补水泵2", "-", "-"));
        pumpList.add(new Pump("补水泵3", "-", "-"));
        return pumpList;
    }

    /**
     * 整理大屯的设备状态数据
     *
     * @param facilityMap 大屯设备状态数据
     * @return 整理后的大屯设备状态数据
     */
    public static List<FacilityState> getFacilityStateList(Map<String, String> facilityMap) {
        // 整理后的大屯设备状态数据
        List<FacilityState> facilityState = new ArrayList<>();
        facilityState.add(createFacilityState("锅炉1", facilityMap.get("10001"), facilityMap.get("10002")));
        facilityState.add(createFacilityState("锅炉2", facilityMap.get("10003"), facilityMap.get("10004")));
        facilityState.add(createFacilityState("锅炉3", facilityMap.get("10005"), facilityMap.get("10006")));
        facilityState.add(createFacilityState("锅炉4", facilityMap.get("10007"), facilityMap.get("10008")));

        facilityState.add(createFacilityState("循环泵1", facilityMap.get("10009"), facilityMap.get("10010")));
        facilityState.add(createFacilityState("循环泵2", facilityMap.get("10011"), facilityMap.get("10012")));
        facilityState.add(createFacilityState("循环泵3", facilityMap.get("10013"), facilityMap.get("10014")));

        facilityState.add(createFacilityState("补水泵1", facilityMap.get("10015"), facilityMap.get("10016")));
        facilityState.add(createFacilityState("补水泵2", facilityMap.get("10017"), facilityMap.get("10017")));

        facilityState.add(createFacilityState("蝶阀1", facilityMap.get("10019"), facilityMap.get("10020")));
        facilityState.add(createFacilityState("蝶阀2", facilityMap.get("10021"), facilityMap.get("10022")));
        facilityState.add(createFacilityState("蝶阀3", facilityMap.get("10023"), facilityMap.get("10024")));
        facilityState.add(createFacilityState("蝶阀4", facilityMap.get("10025"), facilityMap.get("10026")));

        return facilityState;
    }
}
